<?php 
	namespace frontend\controllers;
	use yii;
	use frontend\models\Resume;
	use frontend\models\Personal;
	use yii\web\Controller;
	use yii\web\Cookie;
	class PersonalController extends Controller{
		public $layout = 'index';
		public function actionIndex()
		{
			$model = new Resume();
			$request = Yii::$app->request;
			$post = $request->post();

			$cookies = Yii::$app->request->cookies;
			$uid = $cookies->getValue('user');
			$model->uid = $uid;

			if($request->isPost && $model->load($post))
			{
				$model->save();
				$this->redirect('?r=personal/show');
			}
			// print_r($model);die;
			return $this->render('center',['model'=>$model]);
		}

		public function actionShow()
		{
			$connection=Yii::$app->db; 
			$model = new Resume();
			$request = Yii::$app->request;
			$id = $request->get('id');
			$sql = "select rec.*,res.* from recruit_user as rec LEFT JOIN resume as res on rec.id = res.uid where res.uid='$id'";
			$data = $connection->createCommand($sql)->queryAll();
			// var_dump($data);die;
			$map['data']=$data;
			return $this->render('member_resume',$map);
		}

		public function actionUpdate()
		{
			$request = Yii::$app->request;

			$id = $request->get('id');
			// var_dump($id);die;
			$model = Resume::findOne($id);

			// if($id=='')
			// {
			// 	return $this->render('index');
			// }
			
			$post = $request->post();
			
			if($request->isPost && $model->load($post))
			{
				$model->save(false);
				
			}
			// $data = $model->findOne($id);
			return $this->render('update',['model'=>$model]);
		}
	}

 ?>